import time
from multiprocessing import Process


def method1(name):
    print('method1 %s启动' % name)
    time.sleep(2)
    print('method2% s结束' % name)


def method2(name):
    print('method2 %s启动' % name)
    time.sleep(1)
    print('method2% s结束' % name)


if __name__ == '__main__':
    print("主进程开始")
    for _ in range(5):
        p1 = Process(target=method1, args=('tom',))
        p2 = Process(target=method2, args=('jack',))
        p1.start()
        p2.start()
        p2.join()
        # 终止子进程
        p1.terminate()
        p2.terminate()
print("主进程结束")
